namespace PickGold.Charting
{
    using System;
    using System.Drawing;

    [SRDescription("DescriptionAttributeAnnotationSmartLabels_AnnotationSmartLabels")]
    internal class AnnotationSmartLabel : SmartLabel
    {
        internal override void AddMarkersPosition(CommonElements common, ChartArea area)
        {
            if (((base.smartLabelsPositions.Count == 0) && (common != null)) && (common.Chart != null))
            {
                foreach (Annotation annotation in common.Chart.Annotations)
                {
                    annotation.AddSmartLabelMarkerPositions(base.smartLabelsPositions);
                }
            }
        }

        internal override void DrawCallout(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelStyle smartLabelStyle, PointF labelPosition, SizeF labelSize, StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentStyles labelAlignment)
        {
        }

        internal override bool IsSmartLabelCollide(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelStyle smartLabelStyle, PointF position, SizeF size, PointF markerPosition, StringFormat format, LabelAlignmentStyles labelAlignment, bool checkCalloutLineOverlapping)
        {
            if (common.Chart != null)
            {
                foreach (ChartArea area2 in common.Chart.ChartAreas)
                {
                    if ((area2 != null) && area2.Visible)
                    {
                        area2.smartLabels.checkAllCollisions = true;
                        if (area2.smartLabels.IsSmartLabelCollide(common, graph, area2, smartLabelStyle, position, size, markerPosition, format, labelAlignment, checkCalloutLineOverlapping))
                        {
                            area2.smartLabels.checkAllCollisions = false;
                            return true;
                        }
                        area2.smartLabels.checkAllCollisions = false;
                    }
                }
            }
            RectangleF rect = base.GetLabelPosition(graph, position, size, format, false);
            bool flag2 = (labelAlignment == LabelAlignmentStyles.Center) && !smartLabelStyle.IsMarkerOverlappingAllowed;
            if (base.checkAllCollisions)
            {
                flag2 = false;
            }
            foreach (RectangleF ef2 in base.smartLabelsPositions)
            {
                if (ef2.IntersectsWith(rect))
                {
                    if (flag2)
                    {
                        flag2 = false;
                    }
                    else
                    {
                        return true;
                    }
                }
            }
            return false;
        }
    }
}

